home *** CD-ROM | disk | FTP | other *** search
/ The Utilities Experience / The Utilities Experience - Volume 1.iso / software / misc / o-z / x-windows / mesa-amiwin / src / pb.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-30  |  4.3 KB  |  190 lines

  1. /* pb.h */
  2.  
  3. /*
  4.  * Mesa 3-D graphics library
  5.  * Version:  1.2
  6.  * Copyright (C) 1995  Brian Paul  (brianp@ssec.wisc.edu)
  7.  *
  8.  * This library is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU Library General Public
  10.  * License as published by the Free Software Foundation; either
  11.  * version 2 of the License, or (at your option) any later version.
  12.  *
  13.  * This library is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  * Library General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU Library General Public
  19.  * License along with this library; if not, write to the Free
  20.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  */
  22.  
  23.  
  24. /*
  25. $Id: pb.h,v 1.9 1995/07/15 14:04:10 brianp Exp $
  26.  
  27. $Log: pb.h,v $
  28.  * Revision 1.9  1995/07/15  14:04:10  brianp
  29.  * added PB_WRITE_TEX_PIXEL
  30.  *
  31.  * Revision 1.8  1995/06/20  16:18:39  brianp
  32.  * removed clipflag
  33.  *
  34.  * Revision 1.7  1995/06/12  15:34:47  brianp
  35.  * changed color arrays to GLubyte
  36.  *
  37.  * Revision 1.6  1995/05/22  20:59:34  brianp
  38.  * Release 1.2
  39.  *
  40.  * Revision 1.5  1995/05/17  13:17:22  brianp
  41.  * changed default CC.Mode value to allow use of real OpenGL headers
  42.  * removed need for CC.MajorMode variable
  43.  *
  44.  * Revision 1.4  1995/05/12  16:26:33  brianp
  45.  * added pixel clipping
  46.  *
  47.  * Revision 1.3  1995/03/07  14:21:24  brianp
  48.  * updated for new XSetForeground/GC scheme
  49.  *
  50.  * Revision 1.2  1995/03/04  19:25:29  brianp
  51.  * 1.1 beta revision
  52.  *
  53.  * Revision 1.1  1995/02/24  17:51:57  brianp
  54.  * Initial revision
  55.  *
  56.  */
  57.  
  58.  
  59. #ifndef PB_H
  60. #define PB_H
  61.  
  62.  
  63. #include "GL/gl.h"
  64.  
  65.  
  66.  
  67.  
  68. #define PB_SIZE (3*1024)
  69.  
  70.  
  71. struct pixel_buffer {
  72.     GLint x[PB_SIZE];    /* X window coord in [0,MAX_WIDTH) */
  73.     GLint y[PB_SIZE];    /* Y window coord in [0,MAX_HEIGHT) */
  74.     GLint z[PB_SIZE];    /* Z window coord in [0,MAX_DEPTH) */
  75.     GLubyte r[PB_SIZE];    /* Red */
  76.     GLubyte g[PB_SIZE];    /* Green */
  77.     GLubyte b[PB_SIZE];    /* Blue */
  78.     GLubyte a[PB_SIZE];    /* Alpha */
  79.     GLuint i[PB_SIZE];    /* Index */
  80.     GLfloat s[PB_SIZE];    /* Texture S coordinate */
  81.     GLfloat t[PB_SIZE];    /* Texture T coordinate */
  82.     GLfloat color[4];    /* Mono color */
  83.     GLuint index;        /* Mono index */
  84.     GLuint count;        /* Number of pixels in buffer */
  85.     GLboolean mono;        /* Same color or index for all pixels? */
  86.     GLboolean mutable;    /* Can color or index be modifed during */
  87.                 /* rasterization? */
  88.     GLenum primitive;    /* GL_POINT, GL_LINE, GL_POLYGON or GL_BITMAP*/
  89. };
  90.  
  91.  
  92. extern struct pixel_buffer PB;
  93.  
  94.  
  95.  
  96. /*
  97.  * Set the color used for all subsequent pixels in the buffer.
  98.  */
  99. #define PB_SET_COLOR( C )                \
  100.     if (PB.color[0]!=C[0] || PB.color[1]!=C[1]    \
  101.      || PB.color[2]!=C[2] || PB.color[3]!=C[3]    \
  102.      || !PB.mono) {                    \
  103.         gl_flush_pb();                \
  104.     }                        \
  105.     PB.color[0] = C[0];                \
  106.     PB.color[1] = C[1];                \
  107.     PB.color[2] = C[2];                \
  108.     PB.color[3] = C[3];                \
  109.     PB.mono = GL_TRUE;
  110.  
  111.  
  112. /*
  113.  * Set the color index used for all subsequent pixels in the buffer.
  114.  */
  115. #define PB_SET_INDEX( I )            \
  116.     if (PB.index!=(I) || !PB.mono) {    \
  117.         gl_flush_pb();            \
  118.     }                    \
  119.     PB.index = I;                \
  120.     PB.mono = GL_TRUE;
  121.  
  122.  
  123. /*
  124.  * "write" a pixel using current color or index
  125.  */
  126. #define PB_WRITE_PIXEL( X, Y, Z )    \
  127.     PB.x[PB.count] = X;        \
  128.     PB.y[PB.count] = Y;        \
  129.     PB.z[PB.count] = Z;        \
  130.     PB.count++;
  131.  
  132.  
  133. /*
  134.  * "write" an RGBA pixel
  135.  */
  136. #define PB_WRITE_RGBA_PIXEL( X, Y, Z, R, G, B, A )    \
  137.     PB.x[PB.count] = X;                \
  138.     PB.y[PB.count] = Y;                \
  139.     PB.z[PB.count] = Z;                \
  140.     PB.r[PB.count] = R;                \
  141.     PB.g[PB.count] = G;                \
  142.     PB.b[PB.count] = B;                \
  143.     PB.a[PB.count] = A;                \
  144.     PB.count++;
  145.  
  146. /*
  147.  * "write" a color-index pixel
  148.  */
  149. #define PB_WRITE_CI_PIXEL( X, Y, Z, I )    \
  150.     PB.x[PB.count] = X;        \
  151.     PB.y[PB.count] = Y;        \
  152.     PB.z[PB.count] = Z;        \
  153.     PB.i[PB.count] = I;        \
  154.     PB.count++;
  155.  
  156.  
  157. /*
  158.  * "write" an RGBA pixel with texture coordinates
  159.  */
  160. #define PB_WRITE_TEX_PIXEL( X, Y, Z, R, G, B, A, S, T )    \
  161.     PB.x[PB.count] = X;                \
  162.     PB.y[PB.count] = Y;                \
  163.     PB.z[PB.count] = Z;                \
  164.     PB.r[PB.count] = R;                \
  165.     PB.g[PB.count] = G;                \
  166.     PB.b[PB.count] = B;                \
  167.     PB.a[PB.count] = A;                \
  168.     PB.s[PB.count] = S;                \
  169.     PB.t[PB.count] = T;                \
  170.     PB.count++;
  171.  
  172.  
  173. /*
  174.  * Call this function at least every MAX_WIDTH pixels:
  175.  */
  176. #define PB_CHECK_FLUSH                \
  177.     if (PB.count>=PB_SIZE-MAX_WIDTH) {    \
  178.        gl_flush_pb();            \
  179.     }
  180.  
  181.  
  182. extern void gl_init_pb( GLenum primitive );
  183.  
  184.  
  185. extern void gl_flush_pb( void );
  186.  
  187.  
  188.  
  189. #endif
  190.